<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>销售预测</title>
    <link href="../../component/pear/css/pear.css" rel="stylesheet" />
</head>
<body class="pear-container">

    <div class="layui-card">
        <div class="layui-card-body">
            <table id="analyse-table" lay-filter="analyse-table"></table>
        </div>
    </div>



<script type="text/html" id="role-bar">
    <button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i class="layui-icon layui-icon-edit"></i></button>
    <button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i class="layui-icon layui-icon-delete"></i></button>
</script>


<script src="../../component/layui/layui.js"></script>
<script src="../../component/pear/pear.js"></script>

<script>
    layui.use(['table','form','jquery','upload'],function () {
        let table = layui.table;
        let form = layui.form;
        let $ = layui.jquery;
        let upload= layui.upload;
        let MODULE_PATH = "./analyse/";
        let cols = [
            [
                {type:'checkbox'},
                {title: 'ID', field: 'analyse_ID', align:'center', width:100},
                {title: '月份', field: 'analyse_Month', align:'center', width:100},
                {title: '销售总额', field: 'analyse_Count', align:'center'},
                {title: '同比', field: 'analyse_Common', align:'center'},
                {title: '环比', field: 'analyse_Ring', align:'center'},
                {title: '部门信息', field: 'analyse_Dept', align:'center'},
            ]
        ]

        table.render({
            elem: '#analyse-table',
            url: 'http://localhost:8181/Manager_war/analyseServlet/list',
            page: true ,
            cols: cols ,
            skin: 'line',
            toolbar: '#role-toolbar',
            headers: {
                token: localStorage.getItem("name")
            },
            defaultToolbar: [{
                layEvent: 'refresh',
                icon: 'layui-icon-refresh',
            }, 'filter', 'print', 'exports']
        });

        table.on('tool(analyse-table)', function(obj){
            if(obj.event === 'remove'){
                window.remove(obj);
            } else if(obj.event === 'edit'){
                console.log(obj);
                window.edit(obj);//打开 修改的窗体  并且传入这一行的数据
            } else if(obj.event === 'power'){
                window.power(obj);
            }
        });

        form.on('submit(goods-query)', function(data){
            table.reload('analyse-table',{where:data.field})
            return false;
        });

        window.refresh = function(){
            table.reload('analyse-table');
        }
    })
</script>
</body>
</html>